#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define maxSizeOfVFSName 10
#define avgFileSizeInVFSInBytes 1024
#define maxBlockSize 1024
typedef struct fileDescriptor
{
	char fileName[20];
	char location[100];
	char type;
	long size;
	long blockNumber;
} descriptors;
typedef struct metaHeader
{
	char fileSystemLabel[maxSizeOfVFSName];
	int countOfFileDescriptors;
	int maxDescriptors;
} meta;
typedef struct header
{
	descriptors *desc;
	char *freeList;
} head;

int main()
{
	FILE *fp=fopen("../bin/demo","r");
	if(fp==NULL)
		return -1;
	meta *mh=(meta*)malloc(sizeof(meta));
	int i=0;
	fread(mh,sizeof(meta),1,fp);
	int currentFileDescriptors=mh->countOfFileDescriptors;
	printf("%d\n",currentFileDescriptors);
	int maxFileDescriptors=mh->maxDescriptors;
	int noOfBlocks=maxFileDescriptors/2;
	/*head *h=(head*)malloc(sizeof(descriptors)*maxFileDescriptors+sizeof(char)*(noOfBlocks));
	fread(h,sizeof(descriptors)*maxFileDescriptors+sizeof(char)*(noOfBlocks),1,fp);
	descriptors *desc=(descriptors*)malloc(sizeof(descriptors)*currentFileDescriptors);
	fseek(fp,sizeof(meta),SEEK_SET);*/
	/*int z=0;
	fread(&desc[0],sizeof(descriptors),1,fp);
	printf("%s\n",desc[0].fileName);
	for(z=0;z<currentFileDescriptors;z++)
	{
		fread(&desc[z],sizeof(descriptors),1,fp);
		printf("%s\n",desc[z].fileName);
	}*/
	printf("%d %d %d",maxFileDescriptors,noOfBlocks,sizeof(meta));
	fseek(fp,sizeof(meta)+sizeof(descriptors)*maxFileDescriptors+sizeof(char)*(noOfBlocks),SEEK_SET);
	char *str=(char*)malloc(sizeof(char)*maxBlockSize);
	printf("fread = %d\n",fread(str,maxBlockSize,1,fp));
	printf("\n %s \n",str);
}
